/*
The MIT License (MIT)

Copyright (c) 2013 Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#include <stdio.h>
#include <stdint.h>

# if HHD_PLATFORM_WINDOWS
#	include <Windows.h>
# elif HHD_PLATFORM_OUYA
#	include <pthread.h>
# elif HHD_PLATFORM_LINUX
#	include <pthread.h>
# endif // HHD_PLATFORM

namespace hhd
{
	enum Primitive
	{
		HHD_INT8,
		HHD_INT8X2,
		HHD_INT8X3,
		HHD_INT8X4,

		HHD_UINT8,
		HHD_UINT8X2,
		HHD_UINT8X3,
		HHD_UINT8X4,

		HHD_INT16,
		HHD_INT16X2,
		HHD_INT16X3,
		HHD_INT16X4,

		HHD_UINT16,
		HHD_UINT16X2,
		HHD_UINT16X3,
		HHD_UINT16X4,

		HHD_INT32,
		HHD_INT32X2,
		HHD_INT32X3,
		HHD_INT32X4,

		HHD_UINT32,
		HHD_UINT32X2,
		HHD_UINT32X3,
		HHD_UINT32X4,

		HHD_INT64,
		HHD_INT64X2,
		HHD_INT64X3,
		HHD_INT64X4,

		HHD_UINT64,
		HHD_UINT64X2,
		HHD_UINT64X3,
		HHD_UINT64X4,

	};

	//Integer Types
	typedef ::uint8_t uint8_t;
	typedef ::uint16_t uint16_t;
	typedef ::uint32_t uint32_t;
	typedef ::uint64_t uint64_t;

	typedef ::int8_t int8_t;
	typedef ::int16_t int16_t;
	typedef ::int32_t int32_t;
	typedef ::int64_t int64_t;

	typedef ::uint32_t flag_t;
#ifndef FALSE
#	define FALSE 0
#endif
#ifndef TRUE
#	define TRUE 1
#endif
	typedef ::size_t size_t, index_t;
	typedef ::uintptr_t uintptr_t;

	typedef char char8_t, byte_t;
	typedef unsigned char uchar8_t;
	typedef wchar_t char16_t;

	//Thread Types
# if HHD_PLATFORM_WINDOWS
	typedef HANDLE ThreadHandle;
	typedef unsigned int ThreadId;
	typedef unsigned int ThreadReturnType;

# elif HHD_PLATFORM_OUYA
	typedef pthread_t ThreadHandle;
	typedef pid_t ThreadId;
	typedef void* ThreadReturnType;

# elif HHD_PLATFORM_LINUX
	typedef pthread_t ThreadHandle;
	typedef pid_t ThreadId;
	typedef void* ThreadReturnType;

# endif // HHD_PLATFORM

	//File Types
# if HHD_PLATFORM_WINDOWS
	typedef FILE* FileHandle;

# elif HHD_PLATFORM_OUYA
	typedef FILE* FileHandle;

# elif HHD_PLATFORM_LINUX
	typedef FILE* FileHandle;

# endif // HHD_PLATFORM


// 64bit compatibility for printf and family
#if HHD_PLATFORM_LINUX || HHD_PLATFORM_OUYA
#	define __STDC_FORMAT_MACROS
#	include <inttypes.h>
#	define HHD_U64 PRIu64
#	define HHD_D64 PRId64
#elif HHD_PLATFORM_WINDOWS
#	define HHD_U64 "I64u"
#	define HHD_D64 "I64d"
#endif

}
